package four_day;

import java.util.Random;

/**
 * 给定一个3乘以3的二维数组，里面的数据随机生成。分别求出两个对角线的元素之和
 */
public class DiagonalSum {
    public static void main(String[] args) {
        Random ra = new Random();
        int[][] randomArr = new int[3][3];
        int one = 0;
        int two = 0;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                randomArr[i][j] = ra.nextInt(200) + 100; // 生成下一个伪随机数
                if (i == j) {
                    one += randomArr[i][j];
                } else if ((i + j) == randomArr.length - 1) {
                    two += randomArr[i][j];
                }
            }
        }
//        two = randomArr[0][2] + randomArr[1][1] + randomArr[2][0];
        System.out.println(one + " " + two);
    }
}
